<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<jsp:useBean id="now" class="java.util.Date" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<script type="text/javascript" src="<%=basePath %>js/jquery-1.9.1.min.js"></script>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.css"/>
<link rel="stylesheet" href="<%=basePath %>css/buttons.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<script type="text/javascript">
$(document).ready(function(){
	$("#exit").click(function(){
		location.href = "<%=basePath %>index.jsp";
	});
	setInterval("startRequest()", 10000);	//10秒刷新一次
});
</script>
<script type="text/javascript">
function updateTrain(trainnumber){
	location.href = "<%=basePath %>trainInfo/selById?fid=" + trainnumber;
}
function deleteTrain(trainnumber){
	if(confirm("是否确定删除车次【" + trainnumber + "】的信息？")){
		location.href = "<%=basePath %>trainInfo/del?fid=" + trainnumber;
  	}else{
	  	return false;
  	}
}
function startRequest() 
{ 
	location.href = "<%=basePath %>trainInfo/selAll";
} 
function Dp(trainnumber){
	location.href = "<%=basePath %>trainInfo/selById2?fid="+trainnumber;
}
</script>
<body>
	<center>
		<table border="0" class="table table-hover" width="800">
			<tr>
				<td colspan="9">
					<c:if test="${sessionScope.userBadrecord.fcount != 0 }">
						<img src="<%=basePath%>/img/jingshi.png"  style="width: 40px; height: 50px;"/>
						<label><font color="red" size="2">${msg }</font></label>
					</c:if>
				</td>
			</tr>
		</table>
		<form action="<%=basePath %>trainInfo/selAll" method="post" role="form">
			<table border="0" class="table table-hover" width="800">
				<tr><td colspan="15"><input type="submit" value=" 查  询 " class="button button-pill button-primary" style="width:140px;height:40px;"/>&nbsp;&nbsp;
				<input type="button" value="返回" class="button button-pill button-primary" style="width:140px;height:40px;" id="exit"/></td></tr>
				<tr>
					<td width="100" align="center">车次</td>
					<td width="100" align="center">出发地</td>
					<td width="100" align="center">终点站</td>
					<td width="150" align="center">发车时间</td>
					<td width="150" align="center">到达时间</td>
					<td width="150" align="center">放票时间</td>
					<td width="150" align="center" style="display:none;">系统时间</td>
					<td width="100" align="center">途经1</td>
					<td width="100" align="center">途经2</td>
					<td width="100" align="center">途经3</td>
					<td width="100" align="center">途经4</td>
					<td width="100" align="center">途经5</td>
					<td width="100" align="center">票价</td>
					<td width="100" align="center" style="display:none;">
						余票
					</td>
					<td></td>
					
					<c:forEach items="${trainList }" var="train">
						<tr>
							<td width="100" align="center">${train.trainnumber }</td>
							<td width="100" align="center">${train.startstation }</td>
							<td width="150" align="center">${train.endstation }</td>
							<td width="100" align="center"><fmt:formatDate value="${train.starttime}" type="both" dateStyle="default" timeStyle="default" pattern="yyyy-MM-dd HH:mm:ss"/></td>
							<td width="150" align="center"><fmt:formatDate value="${train.endtime}" type="both" dateStyle="default" timeStyle="default" pattern="yyyy-MM-dd HH:mm:ss"/></td>
							<td width="150" align="center"><fmt:formatDate value="${train.puttickettime}" type="both" dateStyle="default" timeStyle="default" pattern="yyyy-MM-dd HH:mm:ss"/></td>
							<td width="150" align="center" style="display:none;"><fmt:formatDate value="${now}" type="both" dateStyle="default" timeStyle="default" pattern="yyyy-MM-dd HH:mm:ss"/></td>
							<td width="100" align="center">${train.viastaion1 }</td>
							<td width="100" align="center">${train.viastaion2 }</td>
							<td width="100" align="center">${train.viastaion3 }</td>
							<td width="100" align="center">${train.viastaion4 }</td>
							<td width="100" align="center">${train.viastaion5 }</td>
							<td width="100" align="center">${train.price }</td>
							<td width="100" align="center" style="display:none;">${train.total }</td>
							<td>
								<%-- <c:if test="${sessionScope.user.fusername == 'admin'}">
									<input type="button" value="修改"  class="button button-pill button-primary"
										style="width: 70px; height: 30px; font-size: 10px;" id="update" onclick="updateTrain('${train.trainnumber }')"/>
									<input type="button" value="删除" id="del" class="button button-pill button-primary"
										style="width: 70px; height: 30px; font-size: 10px;" onclick="deleteTrain('${train.trainnumber }')"/>
								</c:if> --%>
								<c:if test="${sessionScope.user.fusername != 'admin' && train.total != 0}">
									<input type="button" value="预定" class="button button-pill button-primary"
										style="width: 70px; height: 30px; font-size: 10px;" onclick="Dp('${train.trainnumber }')" 
										<%-- <c:if test="${train.puttickettime > now or sessionScope.userBadrecord.fcount > 1}">disabled</c:if> --%>
										/>
								</c:if>
							</td>
						</tr>
					</c:forEach>
				</tr>	
			</table>
		</form>
	</center>
</body>
</html>